<template>
	<!-- 安全中心 -->
	<view>
		<view class="safe">
			<view class="account" v-for="(item,index) in safeList" :key="index">
				<view class="title">{{item.title}}</view>
				<view class="box">
					<view class="item flex-bc" v-for="(item2,index2) in item.list" :key="index2" @click="handleClick(item2.id,item2.status)">
						<view class="">
							<view class="">
								{{item2.name}}
							</view>
							<view style="color: #666;font-size: 26rpx;">
								{{item2.desc}}
							</view>
						</view>
						<view class="flex-c">
							<image src="../../../static/user/dui.png" v-if="item2.type && item2.status"></image>
							<image src="../../../static/user/tanhao.png" v-if="item2.type && !item2.status"></image>
							<text v-if="item2.type && index2 == 1 && index == 0 && item2.status">已认证</text>
							<text v-if="item2.type && index2 == 1 && index == 0 && !item2.status">未认证</text>
							<text v-if="item2.type && index2 == 2 && index == 0 && item2.status">已绑定</text>
							<text v-if="item2.type && index2 == 2 && index == 0 && !item2.status">未绑定</text>
							<text v-if="item2.type && index2 == 0 && index == 1 && item2.status">已设置</text>
							<text v-if="item2.type && index2 == 0 && index == 1 && !item2.status">未设置</text>
							<uni-icons type="arrowright" size="14" color="#9698A9"></uni-icons>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				token:uni.getStorageSync('token'),
				safeList:[
					{
						title:'账户保护',
						list:[
							{
								name:'登录密码',
								desc:'保证账户安全',
								type:0,
								status:0,
								id:1
							},
							{
								name:'身份证认证',
								desc:'领奖，提款重要信息',
								type:1,
								status:0,
								id:2
							},
							{
								name:'绑定手机号',
								desc:'中奖消息提醒',
								type:1,
								status:0,
								id:3
							}
						]
					},
					{
						title:'资金保护',
						list:[
							{
								name:'提现密码',
								desc:'保证您资金安全',
								type:1,
								status:0,
								id:4
							}
						]
					}
				],
				mobile:'',
				hide_mobile:'',
				realname:'',
				id_card:''
			};
		},
		onLoad() {
			
		},
		onShow() {
			this.fnGetSafeStatus()
		},
		methods:{
			handleClick(type,status){
				var url = ''
				if(type == 1){
					url = 'editPassword'
				}else if(type == 2){
					console.log(status)
					url = `verifiyID?status=${status}&realname=${this.realname}&id_card=${this.id_card}`
				}else if(type == 3){
					url = `bindMobile?hide_mobile=${this.hide_mobile}`
				}else if(type == 4){
					if(status == 1){
						console.log(this.mobile)
						url = `editWithdrawPassword?mobile=${this.mobile}`
					}else{
						url = 'setWithdrawPassword'
					}
					
				}
				uni.navigateTo({
					url: url
				})
			},
			fnGetSafeStatus(){
				this.request({
					url: '/czb/user/securityCenter',
					method: 'POST',
					data: {
						'store_id': 1,
						'token':this.token
					},
				}).then((ret) => {
					console.log(ret);
					if (ret.code == 0) { 
						var data = ret.data
						this.safeList[0].list[1].status = data.id_card_status
						this.safeList[0].list[2].status = data.mobile_status
						this.safeList[1].list[0].status = data.withdraw_status
						this.mobile = data.mobile
						this.hide_mobile = data.hide_mobile
						this.id_card = data.id_card
						this.realname = data.realname
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.account{
		.title{
			padding: 30rpx 20rpx;
			font-size: 30rpx;
		}
		.item{
			height: 120rpx;
			background: #fff;
			padding: 0 20rpx;
			font-size: 28rpx;
			margin-bottom: 20rpx;
			image{
				width: 30rpx;
				height: 30rpx;
			}
			text{
				margin: 0 10rpx;
			}
		}
	}
	
</style>
